# delimit ;
clear ;
cd "replication" ;
set more off ; 

* *************************************************************************** ;
* re-run midline analysis
* *************************************************************************** ;

cd ".." ;
do "./replication/do/table03-midline-knowledge-aggregate.do" ; 

****************************************************************************** ;
* robustness check
****************************************************************************** ;

* excluding subjects assigned to counseling and/or goal setting ; 
drop if financial_counseling == 1 | financial_goal_setting == 1 ;

est drop _all ;

* regressions: agggregate scores ; 
foreach var of varlist score* { ; 

	areg `var' healthonly healthandpay, a(strata) robust ;
	qui est sto `var'; 
	
	test healthonly = healthandpay ; 
	estadd local titlerow = "" ; 
	estadd scalar fstat = r(F): `var' ; 
	estadd scalar pval = r(p): `var' ; 

	summarize `var' if control == 1 & e(sample) == 1;
	estadd scalar cmean = r(mean): `var' ; 
	estadd scalar csd = r(sd): `var' ;

} ;

esttab score* using "./output/appendix-table-midline-knowledge-aggregate-excluding-couns-goal.tex",
	replace
	drop(_cons) 
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(titlerow fstat pval cmean csd N, fmt(%9s %9.3f %9.3f %9.3f %9.3f %9.0f) labels("\(F\)-test, HEE = HEEC" "$\qquad$ \(F\)-statistic" "$\qquad$ \(p\)-value" "Control Mean" "Control SD" "N"))
prehead(\begin{table}[t!] \centering \small `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"'
		\captionsetup{justification=centering} 
		\caption{Effects on Short-Term Health Knowledge \\ Robustness Check, Pure Placebo Group}
		\label{appendix-table-midline-knowledge-aggregate-excluding-couns-goal}
		\begin{tabular*}{0.82\hsize}{p{3.8cm}p{1.9cm}p{1.9cm}p{1.9cm}p{1.9cm}}
		\toprule)
	legend label  booktabs  collabels( , none)
	mgroups(
	"All Topics" 
	"By Topic" 
	, pattern(1 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	postfoot(`"\bottomrule"'  \end{tabular*} \captionsetup{justification=justified, width=0.82\hsize} 
		\caption*{\footnotesize \textit{Notes:} Re-estimation of Table \ref{table-midline-knowledge-aggregate},
		but excluding respondents in the placebo film group who were randomized into additional financial-related
		treatments (i.e., financial counseling and/or goal setting). Thus, the control group in this regression
		consists of respondents who were assigned to only financial films.
		***\$\,p < 0.01$, **\$\,p < 0.05$, *\$\,p<0.10$.
		}
		\end{table}) ;

exit ;
